package com.hopes.bizz.poll.monitor.dto;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.hopes.bizz.common.core.util.StringUtils;
import com.hopes.bizz.poll.monitor.entity.PollMonitorSiteEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;
import java.util.List;

/**
 * @author daijie
 * @version 1.0
 * @date 2023/9/20 13:40
 * @Description:
 */
@Data
public class PollMonitorSiteDTO implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * id
     */
    @TableId(type = IdType.ASSIGN_ID)
    @Schema(description="id")
    private Long id;

    /**
     * 所属乡镇
     */
    @Schema(description="所属乡镇")
    private Long townId;

    /**
     * 站点大类
     */
    @Schema(description="站点大类")
    private Integer monitorTypeMain;

    /**
     * 监控类型
     */
    @Schema(description="监控类型")
    private String monitorType;

    /**
     * 监控点名称
     */
    @Schema(description="监控点名称")
    private String name;

    /**
     * 监控点编号
     */
    @Schema(description="监控点编号")
    private String code;

    /**
     * 运维企业
     */
    @Schema(description="运维企业")
    private String operationOrgName;

    /**
     * 排放方式
     */
    @Schema(description="排放方式")
    private Integer dischargeType;

    /**
     * 排放规律
     */
    @Schema(description="排放规律")
    private Integer dischargeLaw;

    /**
     * 排放去向
     */
    @Schema(description="排放去向")
    private String dischargeDirection;

    /**
     * 监控点位置
     */
    @Schema(description="监控点位置")
    private String monitorLocation;

    /**
     * 定位
     */
    @Schema(description="定位")
    private String gisLocation;

    /**
     * 经度
     */
    @Schema(description="经度")
    private String longitude;

    /**
     * 维度
     */
    @Schema(description="维度")
    private String latitude;

    /**
     * 高度
     */
    @Schema(description="高度")
    private String altitude;

    /**
     * 是否使用
     */
    @Schema(description="是否使用")
    private Boolean isUse;

    /**
     * 是否在线采集
     */
    @Schema(description="是否在线采集")
    private Boolean isOnline;

    /**
     * 监测因子名
     */
    @Schema(description="监测因子名")
    private String monitorFactorNames;

    /**
     * 是否报警
     */
    @Schema(description="是否报警")
    private Boolean alarmFlag = false;

    /**
     * 是否断网
     */
    @Schema(description="是否断网")
    private Boolean netFlag = false;

    /**
     * 监控点状态
     */
    @Schema(description="监控点状态")
    private Integer siteStatus;

    /**
     * AQI站点标记
     */
    @Schema(description="AQI站点标记")
    private Boolean aqiFlag;

    /**
     * 监控点图片
     */
    @Schema(description="监控点图片")
    private String imgFile;

    /**
     * 监控点视频
     */
    @Schema(description="监控点视频")
    private String videoIds;

    private List<String> videoIdList;

    /**
     * 是否关联视频
     */
    @Schema(description="是否关联视频")
    private Boolean videoAssociation;

    /**
     * 排序号
     */
    @Schema(description="排序号")
    private Integer sortNum;

    /**
     * 备注
     */
    @Schema(description="备注")
    private String remarks;

    /**
     * orgId
     */
    @Schema(description="orgId")
    private Long orgId;


    public PollMonitorSiteEntity toPO() {
        PollMonitorSiteEntity entity = new PollMonitorSiteEntity();
        BeanUtils.copyProperties(this, entity);

        if (StringUtils.isNotBlank(this.videoIdList)) {
            StringBuilder builder = new StringBuilder();
            for (String id : this.videoIdList) {
                builder.append(id).append(",");
            }
            builder.deleteCharAt(builder.length() - 1);
            entity.setVideoIds(builder.toString());
        }
        return entity;
    }
}
